package invoker;

import command.Command;

import java.util.ArrayList;
import java.util.List;

public class Waiter {

    //持有多个命令对象
    private List<Command> commands = new ArrayList<>();

    public void setCommand(Command command){
        commands.add(command);
    }

    //发起命令功能
    public void orderUp(){
        System.out.println("服务员:订单来了");
        commands.stream().forEach(command -> {
            if(command!=null){
                command.execute();
                System.out.println();
            }
        });
    }
}
